﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.Enums;
using RoadTeam.Model;
using System.Threading;

namespace RoadTeam.BLL
{
   public class BllBase
    {
       /// <summary>
       /// 插入数据库
       /// </summary>
       /// <param name="Json">传入的数据集合</param>
       public void InserLog(String Json)
       {
           SysLog log = new SysLog();
           log.DataText = Json;
           log.CreateDate = DateTime.Now;
           SysLog.InserObjedct(log, GlobalConfig.ConnectionString);
       }

       /// <summary>
       /// 将日志信息插入数据库
       /// </summary>
       /// <param name="Json"></param>
       /// <param name="ClassPath"></param>
       /// <param name="MethodName"></param>
       public void InsertLog(String Json, String ClassPath, String MethodName)
       {
           SysLog log = new SysLog();
           log.DataText = Json;
           log.CreateDate = DateTime.Now;
           log.ClassPath = ClassPath;
           log.MethodName = MethodName;
           //SysLog.InserObjedct(log, GlobalConfig.ConnectionString);
           //利用多线程插入日志,避免插入时影响主线程性能
           //陈柯良 2013年11月12日1:35:33
           TreadInsertLog insertlog = new TreadInsertLog();
           insertlog.log = log;
           Thread thread = new Thread(new ThreadStart(insertlog.InsertLog));
           thread.Start();
       }
   }

   public class TreadInsertLog
   {
       public SysLog log{get;set;}
       public void InsertLog()
       {
           SysLog.InserObjedct(log, GlobalConfig.ConnectionString);
       }
   }









}
